package com.zhen.aikan.controller;

import com.zhen.aikan.entity.User;
import com.zhen.aikan.service.ILoginService;
import com.zhen.aikan.vo.Result;
import com.zhen.aikan.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author LiJiaZhen
 * @date 2023/9/20 14:54
 */
@Api(tags = "登录控制器")
@RestController
@RequestMapping("/api/login")
public class LoginController {
    @Autowired
    private ILoginService loginService;

    @ApiOperation("用户登录操作")
    @PostMapping("/login")
    public Result login(@RequestBody UserVo userVo) {
        Map<String, Object> msg = loginService.login(userVo);
        return Result.ok(msg);
    }

    @ApiOperation("用户登出操作")
    @GetMapping("/logout")
    public Result logout(@RequestParam(name = "token",defaultValue = "") String token) {
        Map<String,Object> msg = loginService.logout(token);
        return Result.ok(msg);
    }
}
